home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-21 | 2.7 KB | 119 lines | [TEXT/CWIE] |
- // CURLTestDialog.cp ©1997 John C. Daub. All rights reserved.
-
- // This is the dialog handler used to demonstrate the CURLPushButton PowerPlant
- // class. It's just a hack to demonstrate, not necessarily good coding
- // practice.
-
- #include "CURLTestDialog.h"
- #include "CURLPushButton.h"
- #include <UModalDialogs.h>
- #include <LPane.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
-
- const ResIDT PPob_Demo = 128;
-
- void
- CURLTestDialog::DoAboutBox( LCommander *inSuper )
- {
- // get the dialog handler
-
- CURLTestDialog *theHandler = new CURLTestDialog( PPob_Demo, inSuper );
- ThrowIfNil_(theHandler);
-
- // make the handler listen to the CURLPushButton's
- // Isn't this just UGLY? :-)
-
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(1))->AddListener(theHandler);
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(2))->AddListener(theHandler);
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(3))->AddListener(theHandler);
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(4))->AddListener(theHandler);
-
- // we want the last button to demo the use of InvertRect
-
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(4))->SetUseInvertRect(true);
-
- #if _CURLPushButton_DO_DND_
- // we want #2 to not support drag and drop
- ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(2))->SetDoDragAndDrop(false);
- #endif
-
- // show it and do it
-
- theHandler->GetDialog()->Show();
-
- MessageT theMessage;
-
- do {
- theMessage = theHandler->DoDialog();
- } while ( theMessage != msg_OK );
-
- delete theHandler;
- }
-
- CURLTestDialog::CURLTestDialog( ResIDT inDialogResID, LCommander *inSuper )
- : StDialogHandler( inDialogResID, inSuper )
- {
- mICWorking = false; // assume failure
-
- mIC = new CInternetConfig( 'CüRL' ); // test application signature
-
- if ( mIC )
- {
- OSErr err;
-
- err = mIC->Start();
-
- if ( err == noErr )
- mICWorking = true;
- else
- mICWorking = false;
- }
- else
- {
- mICWorking = false;
- }
- }
-
- CURLTestDialog::~CURLTestDialog()
- {
- delete mIC;
- mIC = nil;
- }
-
- void
- CURLTestDialog::ListenToMessage( MessageT inMessage, void* ioParam )
- {
- #pragma unused (ioParam)
-
- mMessage = inMessage; // store message for DoDialog to return
-
- Str255 theURL = "\p";
-
- if ( (mMessage == 'WWW ') && mICWorking )
- {
- ((CURLPushButton*)(GetDialog())->FindPaneByID(1))->GetURL(theURL);
- mIC->DoURL( theURL );
- }
-
- if ( (mMessage == 'MWww') && mICWorking )
- {
- ((CURLPushButton*)(GetDialog())->FindPaneByID(2))->GetURL(theURL);
- mIC->DoURL( theURL );
-
- }
-
- if ( (mMessage == 'Mail') && mICWorking )
- {
- ((CURLPushButton*)(GetDialog())->FindPaneByID(3))->GetURL(theURL);
- mIC->DoURL( theURL );
- }
-
- if ( (mMessage == 'FTP ') && mICWorking )
- {
- ((CURLPushButton*)(GetDialog())->FindPaneByID(4))->GetURL(theURL);
- mIC->DoURL( theURL );
-
- }
-
- }